/*
 * @Author: 康为 18037890117@163.com
 * @Date: 2023-07-05 09:41:50
 * @LastEditors: 康为 18037890117@163.com
 * @LastEditTime: 2023-08-07 13:23:57
 * @FilePath: /umi-max/src/utils/format.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { split, forEach } from 'lodash';

export function getUrlAllParams(name?: string) {
  const url = decodeURI(window.location.href);
  const res: Record<string, string> = {};
  const urlData = split(url, '?').length > 1 ? split(url, '?')[1] : null;
  if (!urlData) {
    return null
  };
  const paramsData = split(urlData,'&')
  forEach(paramsData, item => {
    const key = split(item, '=')[0];
    const value = split(item, '=')[1];
    res[key] = value;
  })
  if (name) {
    return res[name]
  }
  return res
}